﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Ccit.Utils;
using System.Collections.Generic;
using Ccit.OA.MsPersonDoc;

namespace Ccit.OA.PersonDoc
{
    public class PersonDocBLL
    {
        private IPersonDoc iPersonDoc = null;
        public PersonDocBLL()
        {
            iPersonDoc = (IPersonDoc)Factory.CreateObject("Ccit.OA.PersonDoc.dll", "Ccit.OA.persondoc.PersonDoc",
                                                ImportComponentType.DotNetDll, null);
        }
        #region 获取空间设置信息
        /// <summary>
        /// 获取空间设置信息
        /// </summary>
        /// <param name="sQuery"></param>
        /// <returns></returns>
        public DataSet GetPersonDocSpaceMess(string sQuery)
        {
            DataSet dSet = iPersonDoc.GetPersonDocSpaceMess(sQuery);
            iPersonDoc = null;
            return dSet;
        }

        public DataSet GetPersonDocfolder(MsFolder Ms, string sQuery, string sType)
        {
            DataSet dSet = iPersonDoc.GetPersonDocfolder(Ms, sQuery, sType);
            iPersonDoc = null;
            return dSet;
        }
        /// <summary>
        /// 设置空间大小
        /// </summary>
        /// <param name="Ms"></param>
        /// <returns></returns>
        public List<string> DoOperateSpace(MsPersonDocSpace Ms)
        {
            List<string> lstResult = iPersonDoc.DoOperateSpace(Ms);
            iPersonDoc = null;
            return lstResult;
        }
        /// <summary>
        /// 保存文件夹信息

        /// </summary>
        /// <param name="ms"></param>
        /// <returns></returns>
        public List<string> DoSaveFloderMess(MsFolder ms)
        {
            List<string> lstResult = iPersonDoc.DoSaveFloderMess(ms);
            iPersonDoc = null;
            return lstResult;
        }

        public DataSet GetFilesMess(MsFiles Ms, string sType)
        {
            return iPersonDoc.GetFilesMess(Ms, sType);
        }

        /// <summary>
        /// 释放消息对象
        /// </summary>
        public void Release()
        {
            iPersonDoc = null;
        }
        #endregion

        #region
        public MsFolder DelFiles(MsFiles Ms)
        {
            return iPersonDoc.DelFiles(Ms);
        }
        #endregion

        #region
        public MsFiles AddFile(MsFiles Ms)
        {
            return iPersonDoc.insertFile(Ms);
        }
        #endregion
        #region 共用方法
        /// <summary>
        /// 返回文件类型 文字
        /// </summary>
        /// <param name="sType"></param>
        public string GetTypetxt(string sType)
        {
            string sReturn;
            #region 返回文件类型
            switch (sType.ToLower())
            {
                case "":
                    sReturn = "文件夹";
                    break;
                case "txt":
                    sReturn = "文本文件";
                    break;
                case "doc":
                    sReturn = "Word文件";
                    break;
                case "exe":
                    sReturn = "安装文件";
                    break;
                case "rar":
                    sReturn = "压缩文件";
                    break;
                case "zip":
                    sReturn = "压缩文件";
                    break;
                case "xlsx":
                    sReturn = "Excel文件";
                    break;
                case "xls":
                    sReturn = "Excel文件";
                    break;
                case "dll":
                    sReturn = "动态链接文件";
                    break;
                case "pdf":
                    sReturn = "Adobe文档";
                    break;
                case "gif":
                    sReturn = "图片文件";
                    break;
                case "jpg":
                    sReturn = "图片文件";
                    break;
                case "ICO":
                    sReturn = "位图文件";
                    break;
                case "bmp":
                    sReturn = "图片文件";
                    break;
                case "PNG":
                    sReturn = "图片文件";
                    break;
                case "dxf":
                    sReturn = "CAD文件";
                    break;
                default:
                    sReturn = "其它文件";
                    break;
            }
            #endregion
            return sReturn;
        }

        /// <summary>
        /// 返回文件类型 图片
        /// </summary>
        /// <param name="sType"></param>
        /// <returns></returns>
        public string GetTypeimage(string sType)
        {
            string sReturn = "";
            #region 返回文件类型
            switch (sType.ToLower())
            {
                case "":
                    sReturn = "folder_open.gif";
                    break;
                case "aac":
                    sReturn = "aac.gif";
                    break;
                case "ace":
                    sReturn = "ace.gif";
                    break;
                case "ai":
                    sReturn = "ai.gif";
                    break;
                case "ain":
                    sReturn = "ain.gif";
                    break;
                case "amr":
                    sReturn = "amr.gif";
                    break;
                case "app":
                    sReturn = "app.gif";
                    break;
                case "arj":
                    sReturn = "arj.gif";
                    break;
                case "asf":
                    sReturn = "asf.gif";
                    break;
                case "asp":
                    sReturn = "asp.gif";
                    break;
                case "aspx":
                    sReturn = "aspx.gif";
                    break;
                case "av":
                    sReturn = "av.gif";
                    break;
                case "bin":
                    sReturn = "bin.gif";
                    break;
                case "avi":
                    sReturn = "avi.gif";
                    break;
                case "bmp":
                    sReturn = "bmp.gif";
                    break;
                case "cab":
                    sReturn = "cab.gif";
                    break;
                case "cat":
                    sReturn = "cat.gif";
                    break;
                case "cdr":
                    sReturn = "cdr.gif";
                    break;
                case "chm":
                    sReturn = "chm.gif";
                    break;
                case "com":
                    sReturn = "com.gif";
                    break;
                case "css":
                    sReturn = "css.gif";
                    break;
                case "cur":
                    sReturn = "cur.gif";
                    break;
                case "dat":
                    sReturn = "dat.gif";
                    break;
                case "dll":
                    sReturn = "dll.gif";
                    break;
                case "dmv":
                    sReturn = "dmv.gif";
                    break;
                case "doc":
                    sReturn = "doc.gif";
                    break;
                case "dot":
                    sReturn = "dot.gif";
                    break;
                case "dps":
                    sReturn = "dps.gif";
                    break;
                case "dpt":
                    sReturn = "dpt.gif";
                    break;
                case "dwg":
                    sReturn = "dwg.gif";
                    break;
                case "dxf":
                    sReturn = "dxf.gif";
                    break;
                case "emf":
                    sReturn = "emf.gif";
                    break;
                case "eps":
                    sReturn = "eps.gif";
                    break;
                case "et":
                    sReturn = "et.gif";
                    break;
                case "ett":
                    sReturn = "ett.gif";
                    break;
                case "exe":
                    sReturn = "exe.gif";
                    break;
                case "fla":
                    sReturn = "fla.gif";
                    break;
                case "ftp":
                    sReturn = "ftp.gif";
                    break;
                case "gif":
                    sReturn = "gif.gif";
                    break;
                case "hlp":
                    sReturn = "hlp.gif";
                    break;
                case "htm":
                    sReturn = "htm.gif";
                    break;
                case "html":
                    sReturn = "html.gif";
                    break;
                case "icl":
                    sReturn = "icl.gif";
                    break;
                case "ico":
                    sReturn = "ico.gif";
                    break;
                case "img":
                    sReturn = "img.gif";
                    break;
                case "inf":
                    sReturn = "inf.gif";
                    break;
                case "ini":
                    sReturn = "ini.gif";
                    break;
                case "iso":
                    sReturn = "iso.gif";
                    break;
                case "jpeg":
                    sReturn = "jpeg.gif";
                    break;
                case "jpg":
                    sReturn = "jpg.gif";
                    break;
                case "js":
                    sReturn = "js.gif";
                    break;
                case "m3u":
                    sReturn = "m3u.gif";
                    break;
                case "max":
                    sReturn = "max.gif";
                    break;
                case "mdb":
                    sReturn = "mdb.gif";
                    break;
                case "mde":
                    sReturn = "mde.gif";
                    break;
                case "mht":
                    sReturn = "mht.gif";
                    break;
                case "mid":
                    sReturn = "mid.gif";
                    break;
                case "midi":
                    sReturn = "midi.gif";
                    break;
                case "mov":
                    sReturn = "mov.gif";
                    break;
                case "mp3":
                    sReturn = "mp3.gif";
                    break;
                case "mp4":
                    sReturn = "mp4.gif";
                    break;
                case "mpeg":
                    sReturn = "mpeg.gif";
                    break;
                case "mpg":
                    sReturn = "mpg.gif";
                    break;
                case "msi":
                    sReturn = "msi.gif";
                    break;
                case "nrg":
                    sReturn = "nrg.gif";
                    break;
                case "ocx":
                    sReturn = "ocx.gif";
                    break;
                case "ogg":
                    sReturn = "ogg.gif";
                    break;
                case "ogm":
                    sReturn = "ogm.gif";
                    break;
                case "pdf":
                    sReturn = "pdf.gif";
                    break;
                case "png":
                    sReturn = "png.gif";
                    break;
                case "pot":
                    sReturn = "pot.gif";
                    break;
                case "ppt":
                    sReturn = "ppt.gif";
                    break;
                case "psd":
                    sReturn = "psd.gif";
                    break;
                case "pub":
                    sReturn = "pub.gif";
                    break;
                case "qt":
                    sReturn = "qt.gif";
                    break;
                case "ra":
                    sReturn = "ra.gif";
                    break;
                case "ram":
                    sReturn = "ram.gif";
                    break;
                case "rar":
                    sReturn = "rar.gif";
                    break;
                case "rm":
                    sReturn = "rm.gif";
                    break;
                case "rmvb":
                    sReturn = "rmvb.gif";
                    break;
                case "rtf":
                    sReturn = "rtf.gif";
                    break;
                case "swf":
                    sReturn = "swf.gif";
                    break;
                case "tar":
                    sReturn = "tar.gif";
                    break;
                case "tif":
                    sReturn = "tif.gif";
                    break;
                case "tiff":
                    sReturn = "tiff.gif";
                    break;
                case "txt":
                    sReturn = "txt.gif";
                    break;
                case "url":
                    sReturn = "url.gif";
                    break;
                case "vbs":
                    sReturn = "vbs.gif";
                    break;
                case "vsd":
                    sReturn = "vsd.gif";
                    break;
                case "vss":
                    sReturn = "vss.gif";
                    break;
                case "vst":
                    sReturn = "vst.gif";
                    break;
                case "wav":
                    sReturn = "wav.gif";
                    break;
                case "wave":
                    sReturn = "wave.gif";
                    break;
                case "wm":
                    sReturn = "wm.gif";
                    break;
                case "wma":
                    sReturn = "wma.gif";
                    break;
                case "wmd":
                    sReturn = "wmd.gif";
                    break;
                case "wmf":
                    sReturn = "wmf.gif";
                    break;
                case "wmv":
                    sReturn = "wmv.gif";
                    break;
                case "wps":
                    sReturn = "wps.gif";
                    break;
                case "wpt":
                    sReturn = "wpt.gif";
                    break;
                case "xls":
                    sReturn = "xls.gif";
                    break;
                case "xlt":
                    sReturn = "xlt.gif";
                    break;
                case "xml":
                    sReturn = "xml.gif";
                    break;
                case "zip":
                    sReturn = "zip.gif";
                    break;
                default:
                    sReturn = "unknown.gif";
                    break;
            }
            #endregion
            return sReturn;
        }
        #endregion

        #region
        /// <summary>
        /// 文件剪切或复制

        /// </summary>
        /// <param name="sFiesId">文件ID串 ,号分隔</param>
        /// <param name="sWork">操作类型 Code复制/Shear剪切</param>
        /// <param name="sType">文件类型串 ,号分隔</param>
        /// <param name="sObjectID">要进行 粘贴的文件夹ID</param>
        /// <param name="sUserId">文件所属用户ID</param>
        public List<string> Fiesmove(string sFiesId, string sWork, string sType, string sObjectID, string sUserId)
        {
            return iPersonDoc.Fiesmove(sFiesId, sWork, sType, sObjectID, sUserId);
        }

        /// <summary>
        /// 检索功能

        /// </summary>
        /// <param name="sQuery">查询条件</param>
        /// <returns>返回符合检索功能的数据集合</returns>
        public DataSet GetFilesSearch(string sQuery)
        {
            return iPersonDoc.GetFilesSearch(sQuery);
        }
        #endregion

        public List<string> GetOthPersons(string sQuery)
        {
            return iPersonDoc.GetOthPersons(sQuery);
        }
        /// <summary>
        /// 空间用户信息
        /// </summary>
        /// <returns></returns>
        public string DoOperateSpaceUser()
        {
            string iNum = iPersonDoc.DoOperateSpaceUser();
            return iNum;
        }
    }
}
